#!/bin/bash -xe



# 生成 static 类型Dockerfile文件
# generate Dockerfile
cat > Dockerfile <<EOF
	# Base image
	FROM hub.xueerqin.net/base/nginx:20
	#FROM nginx:latest

	# MAINTAINER
	#MAINTAINER fuyu
	LABEL operator=xueerqin 
	LABEL app=${project_name} 
	#LABEL env=${deployEnv}

	ARG Env=${deployEnv}

	# SET WORKDIR
	WORKDIR /usr/share/nginx/html

	# ADD
	COPY dist "\\${WORKDIR}" 
	# ADD dist "\\${WORKDIR}" 
	#COPY dist /usr/share/nginx/html
	RUN pwd
	COPY ./default.conf /etc/nginx/conf.d/default.conf

	EXPOSE 80
EOF
echo "Dockerfile 生成!"

# 生成static nginx配置文件
cat > default.conf <<EOF
server {
    listen       80 default_server;
    server_name  localhost;

    #autoindex on;                               
    #autoindex_exact_size off;               
    #autoindex_localtime on;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location ${healthCheck} {
        default_type application/json;
        return 200 '{"msg":"OK", "data":"null", "status":200}';
    }
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }


    #location ${urlPath} {
    #    alias   /usr/share/nginx/html/;
    #    alias   /
    #}

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
EOF
echo "nginx config 生成"

echo "2222"
pwd
mkdir -p dist
find . -name Dockerfile  -prune -o ! -name default.conf ! -name dist  -print0 |cpio -pmd0  dist/


